﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using UIT.ScrumTool.Client.Controller;
using UIT.ScrumTool.Client.Utilities.Team;

namespace UIT.ScrumTool.Client.View.Project
{
    /// <summary>
    /// Interaction logic for UserTheme.xaml
    /// </summary>
    public partial class UserTheme : UserControl
    {
        public UserTheme()
        {
            InitializeComponent();
        }

        private void comboBoxRole_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBox comboBox = sender as ComboBox;
            switch (comboBox.SelectedIndex)
            {
                case 0:  // Scrum Master
                    comboBox.Background = System.Windows.Media.Brushes.Yellow;
                    break;
                case 1:  // Product Owner
                    comboBox.Background = System.Windows.Media.Brushes.SkyBlue;
                    break;
                case 2:  // Developer
                    comboBox.Background = System.Windows.Media.Brushes.Snow;
                    break;
                case 3:  // Tester
                    comboBox.Background = System.Windows.Media.Brushes.SpringGreen;
                    break;
                case 4:  // Visitor
                    comboBox.Background = System.Windows.Media.Brushes.YellowGreen;
                    break;
                default:
                    break;
            }

            // Update Member Info to ProjectUser Table
            ProjectUserCtrl.ProjectUserUpdateRole(comboBox.TabIndex, comboBox.SelectedIndex);
            try
            {
                MemberInfo memberInfo = ((List<MemberInfo>)uctrlProject._listViewMember.ItemsSource).Find(mem => mem.ProjectUserId == comboBox.TabIndex);
                memberInfo.UserRole = comboBox.SelectedIndex;
            }
            catch (Exception)
            {

            }
        }

        private void btnDrag_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                if (uctrlProject.Data != null)
                {
                    TeamTheme.flag = 0;
                    DragDrop.DoDragDrop(uctrlProject.DragSource, uctrlProject.Data, DragDropEffects.Move);                    
                }
            }
            catch (Exception)
            {
                
            }
            
        }
    }
}
